package com.concurrent.sample.business.utils;

import cn.hutool.core.util.IdUtil;
import com.concurrent.sample.business.consts.enums.OrderStatusEnum;
import com.concurrent.sample.business.entity.OrderEntity;
import com.concurrent.sample.business.dto.report.TradeExecReportDTO;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class OrderReportUtils {

  public static List<TradeExecReportDTO> buildExecReport(OrderEntity orderEntity){
    List<TradeExecReportDTO> tradeExecReportDTOS = new ArrayList<>();

    for(OrderStatusEnum orderStatus : OrderStatusEnum.values()){
      TradeExecReportDTO tradeExecReportDTO = new TradeExecReportDTO()
          .setReportId(IdUtil.fastSimpleUUID())
          .setOriginalOrderId(orderEntity.getId())
          .setSymbol(orderEntity.getSymbol())
          .setOrderStatus(orderStatus)
          .setQuantity(orderEntity.getLeaveQty())
          ;

      if(OrderStatusEnum.COMPLETED == orderStatus){
        tradeExecReportDTO.setExecPrice(BigDecimal.valueOf(10));
      }

      tradeExecReportDTOS.add(tradeExecReportDTO);
    }

    Collections.shuffle(tradeExecReportDTOS);
    return tradeExecReportDTOS;
  }
}
